import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicIntegerArray;

public class AtomicIntegerArrayDemo {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger atomicInt = new AtomicInteger(0);

        Thread t1 = new Thread(() -> {
            for(int i = 0; i < 5000;i++ ){
                atomicInt.incrementAndGet();
            }
        });
        Thread t2 = new Thread(() -> {
            for(int i = 0; i < 5000;i++ ){
                atomicInt.incrementAndGet();
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(atomicInt.get());//获取的是10000
    }
}
